# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Adrian Perez de Castro <aperez@igalia.com>

pkgname=signify
pkgver=31
pkgrel=3
pkgdesc='OpenBSD tool to cryptographically sign and verify files'
url='https://github.com/aperezdc/signify'
arch=('loong64' 'x86_64')
license=('BSD')
depends=('glibc' 'libbsd>=0.8')
source=(${url}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
        ${pkgname}-LICENSE-${pkgver}::https://raw.githubusercontent.com/aperezdc/signify/v${pkgver}/COPYING)
sha512sums=('f39597ea278a7eb10b786909752fde59e16405f0bc76c9906f8014e9e7f6801b4733479eec765fb960b6062359954caf54a3460ff67258a9cff93fa978951962'
            'SKIP'
            '5de1345ef929058040975f1106318ac9443fc107d19a12bfbc919a152ddd4dde11c76201722bc5847bad579e5dc4ba467f0947b6f0fce5cc3eccc68d5f4e9dfe')
validpgpkeys=(
  '5AA3BC334FD7E3369E7C77B291C559DBE4C9123B' # Adrián Pérez de Castro <aperez@igalia.com>
)

prepare() {
  cd ${pkgname}-${pkgver}
  # using O_NOFOLLOW doesn't lock anything down here, swapping files
  # without symlinks is still equally open to TOCTOU and it doesn't even
  # matter here. let's prefer supporting symlinked target files.
  sed -E 's/\| ?O_NOFOLLOW//g' -i ./*.c
}

build () {
  cd ${pkgname}-${pkgver}
  make PREFIX=/usr \
    LTO=1 \
    EXTRA_CFLAGS="${CFLAGS} ${CPPFLAGS}" \
    EXTRA_LDFLAGS="${LDFLAGS}" \
    GIT_TAG=''
}

package () {
  cd ${pkgname}-${pkgver}
  make PREFIX=/usr \
    DESTDIR="${pkgdir}" \
    GIT_TAG='' install
  install -Dm644 README.md CHANGELOG.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm644 ../${pkgname}-LICENSE-${pkgver} "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et:
